var server = require('../../../utils/server');
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    username:'',
    password:''
  },
  land: function(){
    let that = this
    let _params={
      username: that.data.username,
      password: that.data.password
    };
    // server.postJSON('/user/login',_params,(res) => {
    //   if (res.data.status == 200) {
    //     // console.log(res)
    //     getApp().globalData.username=that.data.username;
    //     getApp().globalData.token = res.data.list.app_login_token;
    //     wx.navigateBack({
    //       delta: 1
    //     })
    //   };
    // });
      server.send('/user/login', 'POST', _params).then(res => {
          if (res.status == 200) {
              // console.log(res)
              getApp().globalData.username = that.data.username;
              getApp().globalData.token = res.list.app_login_token;
              wx.navigateBack({
                  delta: 1
              })
          };
      })
  },
  bindUsernameInput: function(e){
    // console.log(e.detail.value)
    this.setData({
      username:e.detail.value
    })
  },
  bindPasswordInput: function(e){
    this.setData({
      password: e.detail.value
    })
  },
  goregistered:function(){
    //注册
    wx.navigateTo({
      url: '../../register/index'
    });
  },
  gogetpsd:function(){
    //修改密码
    wx.navigateTo({
      url: '../../land/changepsd/changepsd'
    });
  }
})